<template>
  <div>
    <div class="my-form-container" style="width: 100% !important; height: 100%; margin: 0;">
      <el-form :model="formData">
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>学期</span>
            </div>
            <label>{{ formData.xueqiname }}</label>
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>课程名称</span>
            </div>
            <label>{{ formData.course.courseName }}</label>
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>教学班名称</span>
            </div>
            <el-input class="inputItem" v-model="formData.teachingClass.className" />
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>学时</span>
            </div>
            <el-input class="inputItem" v-model="formData.course.totalHours" />
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>学分</span>
            </div>
            <el-input class="inputItem" v-model="formData.course.credit" />
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>分类</span>
            </div>
            <el-input class="inputItem" v-model="formData.course.subjectType" />
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>教学班主讲</span>
            </div>
            <el-select
              style="width: 67.5%;margin: 8px 0 0 25px;"
              v-model="formData.teachingClass.mainEmployeeIds"
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="item in teaList"
                :key="item.name"
                :label="item.name"
                :value="item.name"
              >
              </el-option>
            </el-select>
            <!-- <el-input class="inputItem" v-model="formData.teachingClass.mainEmployeeIds" /> -->
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>教学班助教</span>
            </div>
            <el-select
              style="width: 67.5%;margin: 8px 0 0 25px;"
              v-model="formData.teachingClass.tas"
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="item in teaList"
                :key="item.name"
                :label="item.name"
                :value="item.name"
              >
              </el-option>
            </el-select>
            <!-- <el-input class="inputItem" v-model="formData.teachingClass.tas" /> -->
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>考核方式</span>
            </div>
            <el-select v-model="formData.course.khfs" style="width: 67.5%;margin: 8px 0 0 25px;" clearable placeholder="请选择考核方式">
              <el-option v-for="(item, index) in examList" :key="index" :value="item.dictKey" :label="item.dictValue" />
            </el-select>
            <!-- <el-input class="inputItem" v-model="formData.course.khfs" /> -->
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>分制</span>
            </div>
            <label>{{ formData.course.pointsSystem }}</label>
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>课下作业成绩所占比例</span>
            </div>
            <label>{{ formData.course.homeworkRatio }}</label>
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>课堂测试成绩所占比例</span>
            </div>
            <label>{{ formData.course.hskeRatio }}</label>
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>期中考试成绩所占比例</span>
            </div>
            <label>{{ formData.course.midExamRatio }}</label>
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>课终考核成绩所占比例</span>
            </div>
            <label>{{ formData.course.finalExamRetio }}</label>
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>选课要求</span>
            </div>
            <label>{{ formData.teachingClass.xkyaoqiul }}</label>
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>额定人数</span>
            </div>
            <el-input class="inputItem" v-model="formData.teachingClass.reserveNum" />
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>最大预选人数</span>
            </div>
            <el-input class="inputItem" v-model="formData.teachingClass.maxNum" />
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>课程负责人</span>
            </div>
            <label>{{ formData.course.courseCharger }}</label>
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>备注</span>
            </div>
            <el-input class="inputItem" v-model="formData.teachingClass.bz" />
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>创建人</span>
            </div>
            <label>{{ formData.teachingClass.createor }}</label>
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>创建时间</span>
            </div>
            <label>{{ formData.teachingClass.createtime }}</label>
          </el-form-item>
        </div>
        <div style="display: flex;">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>最后修改人</span>
            </div>
            <label>{{ formData.teachingClass.updateman }}</label>
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">
              <span>最后修改时间</span>
            </div>
            <label>{{ formData.teachingClass.updatetime }}</label>
          </el-form-item>
        </div>
      </el-form>
    </div>
    <div style="display: flex; justify-content: center;">
      <div class="button-style" style="min-width: 75px; margin-top: 13px; background: #FFF6F0; border: 1px solid #E9B535;" @click="handleSave">
        <span style="color: #E9B535;">保存</span>
      </div>
      <div class="button-style" style="min-width: 75px; margin: 13px 0 0 80px; background: #FFEEEF; border: 1px solid #FA533C;" @click="handleCancel">
        <span style="color: #FA533C;">取消</span>
      </div>
    </div>
  </div>
</template>

<script>
import { xxkkkgl_getClassInfo, updateClassCourseInfo } from '@/api/trainingManagement/place.js'
import { selectDetailsJob } from '@/api/courseAchievement/entryResults.js'
import { queryDictByCode } from '@/api/admin1/check.js'

export default {
  data() {
    return {
      formData: {
        course: {},
        teachingClass: {}
      },
      teaList:[],
      examList:[]
    }
  },
  mounted() {
    const classNo = this.$route.query.id
    xxkkkgl_getClassInfo(classNo).then(res => {
      if (res.data.code === 200) {
        this.formData = res.data.data
      }
    })
    let teacherInfo = {
      bzbm:'',
      xm:''
    };
    selectDetailsJob(teacherInfo).then(res=>{
      if(res.data.code == 200){
        this.teaList = res.data.data
      }
    })
    queryDictByCode('khfsType').then(res => {
      if (res.data.data && res.data.data.length > 0) {
        this.examList = res.data.data[0].childdictBizs
      }
    })
  },
  methods: {
    handleSave: function () {
      const params = {
        xxTeachingClass: {
          classno: this.formData.teachingClass.classNo,
          classname: this.formData.teachingClass.className,
          mainemployeeids: this.formData.teachingClass.mainEmployeeIds,
          tas: this.formData.teachingClass.tas,
          reservenum: this.formData.teachingClass.reserveNum,
          maxnum: this.formData.teachingClass.maxNum,
          bz: this.formData.teachingClass.bz
        },
        xxCourse: {
          id: this.formData.course.id,
          khfs: this.formData.course.khfs,
          totalHours: this.formData.course.totalHours,
          credit: this.formData.course.credit,
          subjectType: this.formData.course.subjectType
        }
      }
      updateClassCourseInfo(params).then(res => {
        if (res.data.code === 200) {
          this.$store.dispatch('tagsView/delView', this.$route)
          this.$router.push({
            path: "/admin/elective/startClassManagement"
          })
          this.$message.success('信息保存成功！')
        } else {
          this.$message.warning('信息保存失败！')
        }
      })
    },
    handleCancel: function () {
      this.$store.dispatch('tagsView/delView', this.$route)
      this.$router.push({
        path: "/admin/elective/startClassManagement"
      })
    }
  }
}
</script>

<style lang="less" scoped>
.button-style {
  float: left;
  background: #f1f8fe;
  border: 1px solid #51aef6;
  width: auto;
  height: 28px;
  line-height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-wrap: nowrap;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  box-sizing: border-box;
  > span {
    font-size: 14px;
    color: #51aef6;
  }
}
.my-form-item {
  width: 100%;
  height: 60px;
  border-bottom: 1px solid rgba(0, 76, 167, 0.39);
  margin-bottom: 0;
  > div {
    display: flex;
    height: 100%;
    &:nth-child(2) {
      .my-form-item-label {
        border-left: 1px solid rgba(0, 76, 167, 0.39);
      }
    }
    .my-form-item-label {
      width: 220px;
      padding-left: 0;
      background: rgba(0, 76, 167, 0.1);
      display: flex;
      flex: none;
      align-items: center;
      justify-content: center;
      color: #004ca7;
      font-size: 16px;
      font-weight: bold;
      border-left: 1px solid rgba(0, 76, 167, 0.39);
    }
    .mustW {
      color: red;
    }
    .el-form-item__content {
      display: flex;
    }
  }
  label {
    width: 100%;
    margin: 10px 30px 0;
    color: #004ca7;
  }
}
.inputItem {
  margin: 8px 25px;
}
</style>
